package com.start_eternity.oasissafewalk.service.impl;
//记录操作的日志
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.start_eternity.oasissafewalk.mapper.LoggMapper;
import com.start_eternity.oasissafewalk.pojo.PageBean;
import com.start_eternity.oasissafewalk.service.LoggService;
import com.start_eternity.oasissafewalk.pojo.Logg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class LoggServiceImpl implements LoggService {

    @Autowired
    private LoggMapper loggMapper;
    //定期删除操作记录
    @Override
    public void delete(long time) {
    loggMapper.delete(time);
    }

    @Override//分页查询
    public PageBean page(Integer page, Integer pageSize, Integer id, LocalDate loggTime, String name) {
        //1.设置分页参数
        PageHelper.startPage(page,pageSize);
        //2.执行查询
        List<Logg> loggList = loggMapper.list(id,loggTime,name);
        Page<Logg> p = (Page<Logg>) loggList;
        //3.封装PageBean对象
        PageBean pageBean = new PageBean(p.getTotal(),p.getResult());
        return pageBean;
    }

    @Override   //记录操作日志
    public void insert(Logg logg) {
        loggMapper.insert(logg);
    }

    //下载操作记录
    @Override
    public List<Logg> getAllData(List<Integer> ids) {
        return loggMapper.getAllData(ids);
    }
}

